package cn.tom.dao;

import cn.tom.entity.Book;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

@Mapper
public interface BookMapper {
    List<Book> findPageType(@Param("start") Integer num, @Param("lines") Integer num2, @Param("typeid") Integer num3);

    int getCountType(@Param("typeid") Integer num);


    Book findById(int i);

    List<Book> findLike(@Param("str") String str, @Param("start") int i, @Param("num") int i2); //模糊查找

    int findLikeNum(@Param("str") String str);

    List<Book> findTopSale(int i); //找销量高的书

    int subtractStock(@Param("id") int i, @Param("num") int num); //减少库存
    int updateStock(@Param("id")int id,@Param("stock")int stock);
    @MapKey(value = "id")
    Map<Integer,Book> findAllStock();

    int addSalenum(@Param("bookid") int id,@Param("num")int num); //增加销量

    int remove(int i);

    void update(Book book);

    void add(Book book);

    int findRecord(@Param("uid") int uid,@Param("bookid")int bookid);

    int addRecord(@Param("uid") int uid,@Param("bookid")int bookid);

    @MapKey(value = "id")
    Map<Integer,Book> findBookStock();

    @MapKey(value = "id")
    Map<Integer,Book> findAll();

    List<Book> findAll2();

}
